<%@ page import="com.afishing.dao.ShopDao" %>
<%@ page import="com.afishing.dao.impl.ShopDaoImpl" %>
<%@ page import="com.afishing.entity.Shop" %>
<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: 王仕鹏
  Date: 2024/11/23
  Time: 14:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>商品列表</title>
</head>
<style>
    table {
        border-right: 1px solid #000000;
        border-bottom: 1px solid #000000;
        text-align: center;
    }

    table th {
        border-left: 1px solid #000000;
        border-top: 1px solid #000000;
    }

    table td {
        border-left: 1px solid #000000;
        border-top: 1px solid #000000;
    }
</style>
<body>
<%
    ShopDao shopDao = new ShopDaoImpl();
    ArrayList<Shop> allShop = shopDao.getAllShop();
%>

<div class="shop_list">
    <table>
        <tr>
            <th>商品图片</th>
            <th>商品名称</th>
            <th>商品描述</th>
            <th>商品价格</th>
            <th>商品数量</th>
        </tr>
        <%
            for (Shop shop : allShop) {
        %>
        <tr>
            <td><img src="<%="imgs/"+shop.getImage()%>" width="200" height="150"  alt="商品图片"></td>
            <td><%=shop.getName()%></td>
            <td><%=shop.getDescription()%></td>
            <td><%=shop.getPrice()%></td>
            <td><%=shop.getAmount()%></td>
            <td><input type="checkbox" onclick=""></td>
        </tr>
        <%
            }
        %>
<%--        添加到购物车按钮--%>
        <tr>
            <td colspan="6">
                <input type="button" value="添加到购物车">
            </td>
        </tr>
    </table>
</div>
</body>
<script>
    let checkValues = [];
    //将选中的商品添加到数组中
    function clickCheckBox() {
        let checkBoxs = document.getElementsByTagName("input");
        for (let i = 0; i < checkBoxs.length; i++) {
            if (checkBoxs[i].type === "checkbox" && checkBoxs[i].checked) {
                checkValues.push(checkBoxs[i].parentNode.parentNode);
            }
        }
    }


</script>
</html>
